package com.tao.china.biz.jdbc.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.tao.china.biz.jdbc.dao.CatsDao;
import com.tao.china.common.jdbc.DbUtil;



/**
 * @author liuchao
 */
public class CatsDaoImpl implements CatsDao {
    
    Statement stmt = null;
    ResultSet rs = null;
    PreparedStatement pstmt = null;
    String sql = null;
    
    public static final String SQL_SELECT = String.format(
        "insert into %s (%s,%s,%s) values (?,?,?)"  ,
        "props",
        "pid",
        "pname",
        "cid"
          );
    
    
    public List<Cats> getCats() throws SQLException{
        Connection conn = DbUtil.getConnection();
        try{
            sql="select * from cat ";
            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
            List<Cats> cats = new ArrayList<Cats>();
            while(rs.next()){
                Cats cat = new Cats();
                Long cid = rs.getLong("cat_id");
                cat.setCid(cid);
                cats.add(cat);
            }
            return cats;
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally{
            DbUtil.close(conn, stmt, rs);
        }
        return null;
    }
    
   
    
   

}
